﻿@model Sykj.Entity.Content
@{
    ViewData["Title"] = "添加文章";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
@section scriptstop
    {
<script type="text/javascript" charset="utf-8" src="~/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="~/ueditor/ueditor.all.min.js"></script>
        }
<div class="layui-bgn"  style="padding-bottom:20px;">
    <form class="layui-form" style="padding: 20px 30px 0 0;">
        <input type="hidden" asp-for="ContentId">
        <div class="layui-form-item">
            <label class="layui-form-label">文章标题</label>
            <div class="layui-col-xs10">
                <input type="text" asp-for="Title" lay-verify="required" class="layui-input">
            </div>
            <div class="layui-tips-danger">
                *必填
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">附标题</label>
            <div class="layui-col-xs10">
                <input type="text" asp-for="SubTitle" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属栏目</label>
            <div class="layui-col-xs10" id="channel">
                <input type="hidden" id="channelId" asp-for="ChannelId" class="layui-input" />
                <input type="text" id="channelName" placeholder="请选择文章所属栏目" asp-for="ChannelName" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章来源</label>
            <div class="layui-col-xs10">
                <input type="text" asp-for="BeFrom" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章内容</label>
            <div class="layui-col-xs10">
                <textarea asp-for="Description" style="width: 100%; height: 200px" name="Description"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">关键词</label>
            <div class="layui-col-xs10">
                <input type="text" asp-for="Keywords" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">缩略图</label>
            <div class="layui-upload">
                <div class="layui-col-xs10">
                    <button type="button" class="layui-btn" id="img">上传图片</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="imgShow" width="100" height="100" src="@Model.ImageUrl">
                    </div>
                    <input type="hidden" name="ImageUrl" id="ImageUrl" value="@Model.ImageUrl">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">外部连接</label>
            <div class="layui-col-xs10">
                <input type="text" asp-for="LinkUrl" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-col-xs10">
                <textarea asp-for="Remary" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">顺序</label>
            <div class="layui-col-xs10">
                <input type="text" asp-for="Sort" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容类型</label>
            <div class="layui-col-xs10">
                <select id="Type" name="Type" lay-verify="required">
                    <option value="">内容类型</option>
                    <option value="0">文章</option>
                    <option value="1">视频</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-xs4"></div>
            <div class="layui-col-xs4">
                <button class="layui-btn" lay-submit lay-filter="edit" id="submit" type="button">提交</button>
                <button id="close" type="button" class="layui-btn layui-btn-primary">关闭</button>
            </div>
        </div>
    </form>
 </div>
    @section scriptsfeet
        {
        <script type="text/javascript">
        layui.config({
            base: '/layuiadmin/' //自定义模块路径
        }).use(['form', 'layer', 'sykjwh','upload'], function () {
            var $ = layui.$, form = layui.form, sykjwh = layui.sykjwh, upload = layui.upload;

            $("#close").click(function () {
                sykjwh.close();
            });

            //普通图片上传
            upload.render({
                elem: '#img'
                , url: '/Upload/Images'
                , done: function (res) {
                    if (res.success === true) {
                        //上传成功
                        $("#ImageUrl").val(res.data.path);
                        $('#imgShow').attr('src', res.data.path);
                    }
                    else {
                        return layer.msg(res.msg);
                    }
                }
            });

            $("#channel").click(function () {
                sykjwh.open('添加参数', '@Url.Action("ChannelTreeList", "cms", new {area = Constant.AREAMANAGER})',400,700);
            });

            form.on('submit(edit)', function (obj) {
                obj.field.channelId = $("#channelId").val();
                //保存
                sykjwh.save('@Url.Action("ContentEdit", "cms", new {area = Constant.AREAMANAGER})', obj.field);
            });
        });

        //实例化编辑器
        var ue = UE.getEditor('Description', {autoHeightEnabled: false});

        </script>
    }
